package com.task.poker.card.container;

import com.task.poker.card.abs.Card;

import java.util.HashMap;

/**
 * Card Container.
 * @author	JiDong
 * @create	November 14.2019
 *
 */
public class CardContainer {
    private static CardContainer container = new CardContainer();
    public HashMap<Integer, Card> mapCard = new HashMap<>();

    public Card getCard(int cardColor, String figure) {
        if (mapCard.containsKey(cardColor)) {
          Card card = mapCard.get(cardColor);
          card.setCard(figure);
          return card;
        } else {
            Card card = CardFactory.newCard(cardColor);
            card.setCard(figure);
            mapCard.put(cardColor, card);
            return card;
        }
    }

    public static CardContainer newInstance() {
        return container;
    }

}
